//
//  SortFilterTeacherVC.m
//  HTP
//
//  Created by admin on 15/12/3.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "SortFilterTeacherVC.h"
#import "TeacherDetailViewController.h"
#import "TeacherCell.h"
@interface SortFilterTeacherVC ()<BaseTableDelgate,UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) BaseTableView   *teactherTable;

@end

@implementation SortFilterTeacherVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self _initView];

    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self _initNav];
    [self.teactherTable reloadData];
}
//TODO: UI 绘制
-(void)_initView{
    [self.view addSubview:self.teactherTable];
}
-(void)_initNav{
    [self addCustomBackBase];
}
//TODO: 重写get方法
-(BaseTableView *)teactherTable{
    if (!_teactherTable) {
        _teactherTable                  = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeihgt - NavHe) style:UITableViewStylePlain withHeadRefresh:NO andFoodRefresh:NO];
        _teactherTable.dataSource       = self;
        _teactherTable.delegate         = self;
        _teactherTable.separatorStyle   = UITableViewCellSeparatorStyleNone;
        _teactherTable.backgroundColor  = [UIColor clearColor];
        _teactherTable.isNeedWhiteBackground = YES;
    }
    return _teactherTable;
}
//TODO: table datasource delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _dataArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return ScreenWidth  - 30 - 20;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10.0;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = UIView.new;
    [view setFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    [view setBackgroundColor:[UIColor clearColor]];
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = UIView.new;
    [view setFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    [view setBackgroundColor:[UIColor clearColor]];
    return view;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *indentifity = @"teacherCell";
    TeacherCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifity];
    if (!cell) {
        cell = [[TeacherCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifity];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    [cell setCellData:[_dataArray objectAtIndex:indexPath.section]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (![USERCONTENT isLoginUser]) {
        [[NSNotificationCenter defaultCenter] postNotificationName:GETUSERLOGIN object:nil];
        return;
    }
    TeacherModel *teacher = (TeacherModel *)[_dataArray objectAtIndex:indexPath.section];
    TeacherDetailViewController *teacherDetail = [[TeacherDetailViewController alloc] init];
    teacherDetail.teacherId = teacher.tchId;
    [self.navigationController pushViewController:teacherDetail animated:YES];
}
//TODO: baseTable Delegate



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
